﻿<div class="container w-xxl w-auto-xs page-signup">
    <div class="signup-container">
        <div class="signup-header">
            <img src="WFRes/_Content/Login/images/LOGO_W.png">
        </div>
        <form name="form">
            <div class="signup-form">
                <div class="signup-text">
                    <span style="margin-bottom: 10px;">万帮业务流程管理系统</span>
                </div>

                <ul id="myTab" class="nav nav-tabs" style="margin-top:-20px;">
                    <li class="active">
                        <a href="#home" data-toggle="tab">钉钉扫码登录</a>
                    </li>
                    <li><a href="#ios" data-toggle="tab">账号密码登录</a></li>
                </ul>

                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane fade in active" id="home">
                        <!--  <iframe src="template/ddLogin.html" width="100%" height="100%"></iframe>-->
                        <div id="login_container" style="height:300px;margin-left: -30px;"></div>
                        <script type="text/javascript">
                            var appId = "dingoal2a6aeljonwhy5hv";
                            // var domanUrl = "http://localhost:8080/starCharge/dindScanLogin/doDingLogin";
                            var domanUrl = "http://118.190.209.10:8080/starCharge/dindScanLogin/doDingLogin";
                            var decodeUrl = "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=" + appId + "&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=" + domanUrl;
                            var encodeUrl = encodeURIComponent(decodeUrl);

                            var hanndleMessage = function (event) {
                                var origin = event.origin;
                                console.log("origin", event.origin);
                                if(origin.indexOf("dingtalk") > -1) { //判断是否来自ddLogin扫码事件。
                                    var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
                                    console.log("loginTmpCode", loginTmpCode);
                                    window.location.href = decodeUrl + "&loginTmpCode=" + loginTmpCode;//跳转到授权链接
                                }
                            };

                            if (typeof window.addEventListener != 'undefined') {
                                window.addEventListener('message', hanndleMessage, false);
                            } else if (typeof window.attachEvent != 'undefined') {
                                window.attachEvent('onmessage', hanndleMessage);
                            }

                            var obj = DDLogin({
                                id:"login_container",//这里需要你在自己的页面定义一个HTML标签并设置id，例如<div id="login_container"></div>或<span id="login_container"></span>
                                goto: encodeUrl,
                                style: "border:none;background-color:#FFFFFF;",
                                width : "365",
                                height: "400"
                            });

                        </script>
                    </div>

                    <div class="tab-pane fade" id="ios" style="margin-top: 20px;">
                        <div class="form-group w-icon">
                            <input name="txtUser" type="text" id="txtUser"
                                   autofocus class="form-control input-lg" size="20" placeholder="{{LanJson.Code}}"
                                   ng-model="userCode" ng-change="removeValid()" ng-keypress="($event.which===13)?loginIn():''" required>
                            <span class="fa fa-user signup-form-icon"></span>
                        </div>
                        <div class="form-group w-icon" style="margin-top:15px;">
                            <input name="txtPassword" type="password" id="txtPassword"
                                   class="form-control input-lg" size="20" placeholder="{{LanJson.Password}}"
                                   ng-model="userPassword" ng-keypress="($event.which===13)?loginIn():''" required>
                            <span class="fa fa-lock signup-form-icon"></span>
                        </div>
                        <div ng-if="validCode" style="line-height: 40px;margin-top: 15px;">验证码：<input id="codevalidate" type="text" style="width: 50%;height:33px;display: inline" class="form-control">
                            <img  ng-src="{{validCodeImg}}" width="90" height="30" style="margin-left: 10px" ng-click="changeUrl()">
                        </div>
                        <!--错误信息-->
                        <div ng-if="loginFail" style="text-align: center;color:#ff0000; margin-top: 15px;">
                            <span>{{errorText}}</span>
                        </div>
                        <!--<div ng-if="!LoginSuccess" style="text-align: center;color:#ff0000; margin-top: 15px;">-->
                        <!--<span translate="LoginController.NotInvalid">用户名密码错误</span>-->
                        <!--</div>-->
                        <!--<div ng-if="!InvalidCodeError" style="text-align: center;color:#ff0000; margin-top: 15px;">-->
                        <!--<span>验证码错误</span>-->
                        <!--</div>-->
                        <!--<div ng-if="!inputInvalidCode" style="text-align: center;color:#ff0000; margin-top: 15px;">-->
                        <!--<span>请输入验证码</span>-->
                        <!--</div>-->
                        <!--<div ng-if="!ConnectionFailed" style="text-align: center;color:#ff0000; margin-top: 15px;">-->
                        <!--<span>引擎连接失败</span>-->
                        <!--</div>-->
                        <!--<div ng-if="!EnginePasswordValid" style="text-align: center;color:#ff0000; margin-top: 15px;">-->
                        <!--<span>引擎连接失败,密码错误</span>-->
                        <!--</div>-->
                        <!--add by luwei@Future 2018.8.10-->
                        <!--<div ng-if="!LoginFailTimesExceed" style="text-align: center;color:#ff0000; margin-top: 15px;">-->
                        <!--<span>登录失败次数超过限制，请24小时后再试</span>-->
                        <!--</div>-->
                        <!-- ng-disabled="form.$invalid" -->
                        <div class="form-actions">
                            <button type="submit"
                                    ng-disabled="loginDisabled"
                                    class="btn btn-lg btn-info btn-block"
                                    style="background-color: #4997D6"
                                    ng-click="loginIn()">
                                <span translate="LoginController.Login">登录</span>
                            </button>
                        </div>
                    </div>
                </div>

            </div>
        </form>
    </div>
</div>